package Test1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Thread_Demo5 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ArrayList<Integer> list = new ArrayList<Integer>();
        Collections.addAll(list, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000);
        //创建多线程要运行的参数对象
        lian_xi_Demo5 l1 = new lian_xi_Demo5(list);
        //创建多线程运行结果管理对象
        FutureTask<Integer> f1 = new FutureTask<>(l1);
        FutureTask<Integer> f2 = new FutureTask<>(l1);
        //创建多线程运行对象
        Thread t1 = new Thread(f1);
        Thread t2 = new Thread(f2);
        //启动多线程
        t1.start();
        t2.start();
        t1.setName("线程抽奖1");
        t2.setName("线程抽奖2");
        if(f1.get()>f2.get()){
            System.out.println("线程1中奖号码最大");
        }else{
            System.out.println("线程2中奖值最大");
        }
    }
}
